--衍生技 博览狂语
local bolankuangyu = fk.CreateSkill {
    name = "mcdh_bolankuangyu",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

bolankuangyu:addEffect(fk.EventPhaseStart,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and target == player and player.phase == Player.Start
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        player:drawCards(2, self.name)
        local cid = room:askForDiscard(player, 1, 1, false, self.name, false, ".", "#mcdh_bolankuangyu-discard")
        local  mark = player:getTableMark("@bolankuangyu-turn")
        local suit = Fk:getCardById(cid[1]):getSuitString(true)
        table.insertIfNeed(mark,suit)
        for _, p in ipairs(room.alive_players) do
            room:setPlayerMark(p, "@bolankuangyu-turn", mark)
        end
    end
})

bolankuangyu:addEffect( fk.Damaged,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and target == player
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        player:drawCards(2, self.name)
        local cid = room:askForDiscard(player, 1, 1, false, self.name, false, ".", "#mcdh_bolankuangyu-discard")
        local  mark = player:getTableMark("@bolankuangyu-turn")
        local suit = Fk:getCardById(cid[1]):getSuitString(true)
        table.insertIfNeed(mark,suit)
        for _, p in ipairs(room.alive_players) do
            room:setPlayerMark(p, "@bolankuangyu-turn", mark)
        end
    end
})

bolankuangyu:addEffect('prohibit',{
    prohibit_use = function(self, player, card)
        local mark = player:getTableMark("@bolankuangyu-turn")
        return #mark ~= 0 and table.contains(mark,card:getSuitString(true))
    end,
})

Fk:loadTranslationTable {
    ["@bolankuangyu-turn"] = " 博览狂语",
    ["mcdh_bolankuangyu"] = "诳言",
    [":mcdh_bolankuangyu"] = "「博览狂语」<br>准备阶段、或你受到伤害后，你可以摸两张牌并弃置一张手牌，本回合所有角色不能使用与你此法弃置牌相同花色的牌。",
    ["#mcdh_bolankuangyu_prohibit"] = "博览狂语",
    ["#mcdh_bolankuangyu-discard"] = "博览狂语:弃置一张手牌"
}

return bolankuangyu